import os
import os.path

user_value = 'sober'
passwd_value = 'python'
numb = 0

while numb < 3:
    r_file = open('F:/test1/day1/lockfile.txt')
    inputuser = input('请输入用户名：')
    in_us_tmp = '%s%s'%(inputuser,'\n')
    #判断用户是否已锁定，如果已锁定，那就退出程序
    if in_us_tmp in r_file.readlines():
        print('您的用户已锁定！')
        break
    #未锁定的用户继续输入用户名密码
    inputpasswd = input('请输入密码：')
    if inputuser == user_value and inputpasswd == passwd_value:
        print('Welcome to Python!!!')
        break
    else:
        print('用户名或密码错误')
    numb += 1
else:
    #将锁信息写入文件
    lockfile = open('F:/test1/day1/lockfile.txt','a')
    lockfile.write(inputuser+'\n')
    lockfile.close()